//================================================================================
// ThrowProjectile.
//================================================================================

class ThrowProjectile extends CrossbowArrow;

var() localized string KnifePickupMessage;

function PostNetBeginPlay ();

simulated state OnWall /*extends OnWall*/
{
  function ProcessTouch (Actor Other, Vector HitLocation)
  {
    local Inventory Inv;
  
    if ( (Pawn(Other) != None) && (Pawn(Other).Inventory != None) ) // 0x00000019 : 0x0000
    {
      Inv = Pawn(Other).Inventory; // 0x00000038 : 0x002B
JL0044:
      if ( Inv != None ) // 0x00000048 : 0x0044
      {
        if ( (Throw(Inv) != None) && (Weapon(Inv).AmmoAmount(0) < Weapon(Inv).MaxAmmo(0)) ) // 0x00000051 : 0x004F
        {
          KFWeapon(Inv).AddAmmo(1,0); // 0x0000007F : 0x0090
          PlaySound(Sound'Ammo_GenericPickup',SLOT_Pain,2.0 * TransientSoundVolume,,400.0); // 0x0000008E : 0x00A6
          if ( PlayerController(Instigator.Controller) != None ) // 0x000000A6 : 0x00C2
          {
            PlayerController(Pawn(Other).Controller).ClientMessage(KnifePickupMessage); // 0x000000B6 : 0x00DB
          }
          Destroy(); // 0x000000CE : 0x0102
          return; // 0x000000D1 : 0x0105
        } else { // 0x000000D3 : 0x0107
          if ( (Throw(Inv) != None) && (Weapon(Inv).AmmoAmount(0) >= Weapon(Inv).MaxAmmo(0)) ) // 0x000000D6 : 0x010A
          {
            return; // 0x00000104 : 0x014B
          }
        }
        Inv = Inv.Inventory; // 0x00000106 : 0x014D
        goto JL0044; // 0x00000114 : 0x0161
      }
      if ( KFHumanPawn(Other).CanCarry(1.0) ) // 0x00000117 : 0x0164
      {
        Pawn(Other).GiveWeapon("UnitedMut_v54.Throw"); // 0x0000012C : 0x0180
        Inv = Pawn(Other).Inventory; // 0x0000014E : 0x01A9
JL01C2:
        if ( Inv != None ) // 0x0000015E : 0x01C2
        {
          if ( Throw(Inv) != None ) // 0x00000167 : 0x01CD
          {
            KFWeapon(Inv).AddAmmo(-24,0); // 0x00000173 : 0x01DD
            KFWeapon(Inv).SellValue = 5; // 0x00000186 : 0x01F7
            PlayerController(Pawn(Other).Controller).ClientMessage("You got the Throwing knife",'CriticalEvent'); // 0x00000195 : 0x020D
            PlaySound(Class'ThrowPickup'.Default.PickupSound,SLOT_Interact); // 0x000001C9 : 0x0250
            Destroy(); // 0x000001D8 : 0x0263
          } else { // 0x000001DB : 0x0266
            Inv = Inv.Inventory; // 0x000001DE : 0x0269
            goto JL01C2; // 0x000001EC : 0x027D
          }
        }
      }
    }
  }
  
  simulated function Tick (float Delta)
  {
    if ( Base == None ) // 0x0000001A : 0x0000
    {
      if ( Level.NetMode == 3 ) // 0x00000023 : 0x000B
      {
        bHidden = True; // 0x00000037 : 0x0024
      } else { // 0x0000003D : 0x002C
        Destroy(); // 0x00000040 : 0x002F
      }
    }
  }
  
  simulated function BeginState ()
  {
    bCollideWorld = False; // 0x00000019 : 0x0000
    if ( Level.NetMode != 1 ) // 0x0000001F : 0x0008
    {
      AmbientSound = None; // 0x00000033 : 0x0021
    }
    if ( Trail != None ) // 0x00000038 : 0x0028
    {
      Trail.mRegen = False; // 0x00000041 : 0x0033
    }
    SetCollisionSize(25.0,25.0); // 0x0000004E : 0x0044
  }
  
}

simulated function HitWall (Vector HitNormal, Actor Wall)
{
  Speed = VSize(Velocity); // 0x0000001A : 0x0000
  if ( (Role == 4) && (Wall != None) ) // 0x00000023 : 0x000D
  {
    if (  !Wall.bStatic &&  !Wall.bWorldGeometry ) // 0x0000003C : 0x002A
    {
      if ( (Instigator == None) || (Instigator.Controller == None) ) // 0x0000005E : 0x0054
      {
        Wall.SetDelayedDamageInstigatorController(InstigatorController); // 0x00000076 : 0x0075
      }
      Wall.TakeDamage(int(Damage),Instigator,Location,MomentumTransfer * Normal(Velocity),MyDamageType); // 0x00000084 : 0x0089
      HurtWall = Wall; // 0x000000A4 : 0x00BC
    }
    MakeNoise(1.0); // 0x000000AB : 0x00C7
  }
  PlaySound(Arrow_hitwall[Rand(3)],,2.5 * TransientSoundVolume); // 0x000000B3 : 0x00CF
  if (! (Level.NetMode != 1) ) goto JL0102; // 0x000000C9 : 0x00E9
  JL0102: if ( (Instigator != None) && (Level.NetMode != 3) ) // 0x000000DD : 0x0102
  {
    MakeNoise(0.31); // 0x000000FB : 0x0128
  }
  Stick(Wall,Location + HitNormal); // 0x00000103 : 0x0130
}

simulated function ProcessTouch (Actor Other, Vector HitLocation)
{
  local Vector X;
  local Vector End;
  local Vector HL;
  local Vector HN;
  local Vector TempHitLocation;
  local Vector HitNormal;
  local array<int> HitPoints;
  local KFPawn HitPawn;
  local bool bHitWhipAttachment;
  local Rotator Rot;

  Rot.Pitch = -14564; // 0x00000019 : 0x0000
  Rot.Yaw = Rotation.Yaw; // 0x00000025 : 0x0010
  Rot.Roll = Rotation.Roll; // 0x00000032 : 0x0025
  if ( (Other == None) || (Other == Instigator) || (Other.Base == Instigator) ||  !Other.bBlockHitPointTraces || (Other == IgnoreImpactPawn) || (IgnoreImpactPawn != None) && (Other.Base == IgnoreImpactPawn) ) // 0x0000003F : 0x003A
  {
    return; // 0x0000009F : 0x00BE
  }
  X = Vector(Rotation); // 0x000000A1 : 0x00C0
  if ( ROBulletWhipAttachment(Other) != None ) // 0x000000AA : 0x00CD
  {
    bHitWhipAttachment = True; // 0x000000B5 : 0x00DD
    if (  !Other.Base.bDeleteMe ) // 0x000000BB : 0x00E5
    {
      Other = Instigator.HitPointTrace(TempHitLocation,HitNormal,HitLocation + 65535 * X,HitPoints,HitLocation,,1); // 0x000000D1 : 0x0102
      if ( (Other == None) || (HitPoints.Length == 0) ) // 0x000000FC : 0x013F
      {
        return; // 0x00000110 : 0x0158
      }
      HitPawn = KFPawn(Other); // 0x00000112 : 0x015A
      if ( Role == 4 ) // 0x0000011B : 0x016A
      {
        if ( HitPawn != None ) // 0x00000129 : 0x017A
        {
          if (  !HitPawn.bDeleteMe ) // 0x00000132 : 0x0185
          {
            HitPawn.ProcessLocationalDamage(int(Damage),Instigator,TempHitLocation,MomentumTransfer * X,MyDamageType,HitPoints); // 0x00000142 : 0x0199
          }
          Damage *= 0; // 0x00000165 : 0x01CF
          Velocity /= 100.0; // 0x0000016D : 0x01D9
          SetRotation(Rot); // 0x00000177 : 0x01E5
          IgnoreImpactPawn = HitPawn; // 0x0000017D : 0x01ED
          if ( Level.NetMode != 3 ) // 0x00000184 : 0x01F8
          {
            PlayhitNoise((Pawn(Other) != None) && (Pawn(Other).ShieldStrength > 0)); // 0x00000198 : 0x0211
          }
          return; // 0x000001B8 : 0x0241
        }
      }
    } else { // 0x000001BA : 0x0243
      return; // 0x000001BD : 0x0246
    }
  }
  if ( Level.NetMode != 3 ) // 0x000001BF : 0x0248
  {
    PlayhitNoise((Pawn(Other) != None) && (Pawn(Other).ShieldStrength > 0)); // 0x000001D3 : 0x0261
  }
  if ( (Physics == 6) && (Pawn(Other) != None) && (Vehicle(Other) == None) ) // 0x000001F3 : 0x0291
  {
    IgnoreImpactPawn = Pawn(Other); // 0x0000021A : 0x02C5
    if ( IgnoreImpactPawn.IsHeadShot(HitLocation,X,1.0) ) // 0x00000222 : 0x02D5
    {
      Other.TakeDamage(int(Damage * HeadShotDamageMult),Instigator,HitLocation,MomentumTransfer * X,DamageTypeHeadShot); // 0x0000023B : 0x02F6
    } else { // 0x0000025E : 0x032E
      Other.TakeDamage(int(Damage),Instigator,HitLocation,MomentumTransfer * X,MyDamageType); // 0x00000261 : 0x0331
    }
    Damage *= 0; // 0x0000027F : 0x0362
    Velocity /= 100.0; // 0x00000287 : 0x036C
    SetRotation(Rot); // 0x00000291 : 0x0378
    return; // 0x00000297 : 0x0380
  } else { // 0x00000299 : 0x0382
    if ( (ExtendedZCollision(Other) != None) && (Pawn(Other.Owner) != None) ) // 0x0000029C : 0x0385
    {
      if ( Other.Owner == IgnoreImpactPawn ) // 0x000002BA : 0x03B0
      {
        return; // 0x000002CB : 0x03C8
      }
      IgnoreImpactPawn = Pawn(Other.Owner); // 0x000002CD : 0x03CA
      if ( IgnoreImpactPawn.IsHeadShot(HitLocation,X,1.0) ) // 0x000002DC : 0x03E3
      {
        Other.TakeDamage(int(Damage * HeadShotDamageMult),Instigator,HitLocation,MomentumTransfer * X,DamageTypeHeadShot); // 0x000002F5 : 0x0404
      } else { // 0x00000318 : 0x043C
        Other.TakeDamage(int(Damage),Instigator,HitLocation,MomentumTransfer * X,MyDamageType); // 0x0000031B : 0x043F
      }
      Damage *= 0; // 0x00000339 : 0x0470
      Velocity /= 100.0; // 0x00000341 : 0x047A
      SetRotation(Rot); // 0x0000034B : 0x0486
      return; // 0x00000351 : 0x048E
    }
  }
  if ( (Level.NetMode != 1) && (SkeletalMesh(Other.Mesh) != None) && (Other.DrawType == 2) && (Pawn(Other) != None) ) // 0x00000353 : 0x0490
  {
    End = Other.Location + X * 600; // 0x0000039D : 0x04F1
    if ( Other.Trace(HL,HN,End,Other.Location,False) != None ) // 0x000003B7 : 0x0515
    {
      Spawn(Class'BodyAttacher',Other,,HitLocation).AttachEndPoint = HL - HN; // 0x000003D8 : 0x0545
    }
  }
  if ( Level.NetMode != 3 ) // 0x000003F4 : 0x056E
  {
    if ( (Pawn(Other) != None) && Pawn(Other).IsHeadShot(HitLocation,X,1.0) ) // 0x00000408 : 0x0587
    {
      Pawn(Other).TakeDamage(int(Damage * HeadShotDamageMult),Instigator,HitLocation,MomentumTransfer * X,DamageTypeHeadShot); // 0x0000042E : 0x05BF
    } else { // 0x00000453 : 0x05FC
      Other.TakeDamage(int(Damage),Instigator,HitLocation,MomentumTransfer * X,MyDamageType); // 0x00000456 : 0x05FF
    }
  }
}

defaultproperties
{
     KnifePickupMessage="You picked up a Throwing Knife"
     DamageTypeHeadShot=Class'UnitedMut_v54.DamTypeThrowHeadShot'
     HeadShotDamageMult=3.000000
     Speed=3000.000000
     MaxSpeed=6000.000000
     Damage=90.000000
     MomentumTransfer=15000.000000
     MyDamageType=Class'UnitedMut_v54.DamTypeThrow'
     LifeSpan=15.000000
     Mesh=SkeletalMesh'Throwing_KnifeV2.throwing_knife_projectile'
     Acceleration=(Z=-500.000000)
     DrawScale=1.150000
}
